<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>Primus</title>
	  
	<link type="text/css" rel="stylesheet" href="/spring-GOP/css/movie/style_10.css">
	<link type="text/css" rel="stylesheet" href="/spring-GOP/css/movie/style_1030.css">
	<link type="text/css" rel="stylesheet" href="/spring-GOP/css/common.css">
	<link type="text/css" rel="stylesheet" href="/spring-GOP/css/style.css">
	
	<script type="text/javascript">
		function thumbClick(url){
			var img = new Image();
	
			  img.onload = function() {
			    var imgW = this.width;
			    var imgH = this.height;
			    if((imgW!=0) && (imgH!=0)) {
			      window.open(url,'guide','width='+imgW+', height='+imgH+', scrollbars=no');
			    }
			  }
			  img.src = url;
		}
		
		var user = '${user}';
		var userId = '${user.member_id}';
		var buy = '${buy}';
		var currentPoint = eval('${user.member_point}');
		var moviePrice = eval('${movie.movie_price}');
		var contentPath = '${content.path}';
		
		function onContentClick() {
			if(userId == "") {
				alert("로그인이 필요합니다.");
			} else {
				if(buy == "") {
					if(confirm("본 상품을 보기위해선 구매해야 합니다. 구매하시겠습니까?")) {
						if(currentPoint < moviePrice) {
							if(confirm("포인트가 부족합니다. 포인트 충전 페이지로 이동하시겠습니까?")) {
								location.href="/spring-GOP/login/checkLogin?idx=" + '${pageIdx}' + "&target=ticket";
							} else return false;
						} else {
							document.buyForm.submit();
						}
					} else {
						alert("구매를 취소하였습니다.");
					}
				} else {
					width = "1000";
				    height="600";
				    width2 = width / 2;
				    height2 = height / 2;
				    ww = screen.width / 2;
				    hh = screen.height / 2;
				    var left = ww - width2;
				    var top = hh - height2 - 100;
				    var url3 = contentPath;
				    var win = window.open(url3,"detail3","width=" + width + ",height=" + height + ",top=" + top + ",left=" + left + ",scrollbars=yes", '_blank');
				    win.focus();
				}
			}
		}
		
		function onBuyClick() {
			
			if(userId == "") {
				alert("회원이시라면 로그인을 해주세요.");
			} else {
				if(userId == "admin") {
					alert("관리자는 구매할 수 없습니다.");
				} else {
					if(buy == "") {
						if(confirm("본 상품을 구매하시겠습니까?")) {
							if(currentPoint < moviePrice) {
								if(confirm("포인트가 부족합니다. 포인트 충전 페이지로 이동하시겠습니까?")) {
									location.href="/spring-GOP/login/checkLogin?idx=" + '${pageIdx}' + "&target=ticket";
								} else return false;
							} else {
								document.buyForm.submit();
							}
						} else {
							alert("구매를 취소하였습니다.");
						}
					} else {
						alert("이미 구매하신 상품입니다.");
					}
				}
			}
		}
	
		function onChargeClick() {
    		if(userId != "") {
   				if(userId != "admin") alert("사용자"); /* location.href="/GOP/pages/ticket/list.jsp"; */
    			else alert("관리자"); /* location.href="/GOP/pages/ticket/start.jsp"; */
    		} else {
    			alert("로그인을 하셔야 합니다.");
    			location.href="/GOP/pages/login/login.jsp";
    		}
		}
	</script>
</head>
<body onLoad="check()">
	<div class="movie-detail-bg" style="background-image: url(${background.path}); visibility: visible;">
		<div class="mov-bg">
		</div>
	</div>
	
	<!-- container -->
	<div id="container">
		<!-- content -->
		<div id="content">
			<!-- main-shortCut -->
			<div id="main-shortCut">

				<!-- sub-main-section -->
				<div class="sub-main-section c10">
					<!-- 컨텐츠 작성 -->
					<div class="page-type1"></div>
					<!-- video player -->
					<object width="853" height="480">
						<param name="movie" value="${trailer.path}"></param>
						<param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>
						<embed src="${trailer.path}" type="application/x-shockwave-flash" width="990" height="536" allowscriptaccess="always" allowfullscreen="true">
						</embed>
					</object>
					<!-- //video player -->
					<!-- description -->
					<div class="description margin-top20 margin-bottom190">
						<div class="poster">
							<img id="imgPoster" src="${poster.path}${poster.file_name}">
							<p><a onclick="javascript:onBuyClick();" class="button h45 w214 orange border">구매하기(\ ${movie.movie_price})</a></p>
							<p><a href="javascript:onContentClick();" class="button h45 w214 orange border">시청하기</a></p>
							<p><a href="/spring-GOP/login/checkLogin?idx=${pageIdx}&target=ticket" class="button h45 w214 white border">포인트 충전</a></p>
							<p><a href="list" class="button h45 w214 gray border">목록으로</a></p>
						</div>
						<!-- movieInfo -->
						<div class="movieInfo" style="background: url('/save/images/movie/common/bg.png') repeat;">
							<div class="info">
								<div class="info-sub">
									<h2>${movie.movie_title}</h2>
									<p class="sub"><b>${movie.movie_title}, ${movie.movie_releasedate.substring(0, 4)}</b></p>
									<div class="script">
										${movie.movie_synopsis}
									</div>
								</div>
								<div class="grade">
									<div class="icon">
										<img src="/save/images/movie/common/over${movie.movie_grade}_big.png">
									</div>

									<div class="line"></div>
									<p class="genre">
										<!-- <b>로맨스</b><br>
										<b>코미디</b> -->
										${movie.movie_genre}
									</p>
									<div class="line"></div>
								</div>
							</div>
							<div class="line"></div>
							<!-- spec -->
							<div class="spec">
								<dl>
									<dt>감독 / 출연</dt>
									<dd>${movie.movie_director} / ${movie.movie_actor}</dd>

									<dt>제작국가 / 장르</dt>
									<dd>${movie.movie_country} / ${movie.movie_genre}</dd>

									<dt>등급 / 개봉일</dt>
									<dd>
										<c:choose>
											<c:when test="${movie.movie_grade == 0}">
												전체관람가
											</c:when>
											<c:when test="${movie.movie_grade == 12}">
												12세이상
											</c:when>
											<c:when test="${movie.movie_grade == 15}">
												15세이상
											</c:when>
											<c:otherwise>
												18세이상
											</c:otherwise>
										</c:choose>
										/ ${movie.movie_releasedate}
									</dd>

									<dt>상영시간 / 홈페이지</dt>
									<dd>${movie.movie_viewtime} / ${movie.movie_homepage}</dd>
								</dl>
							</div>
							<!-- //spec -->
							<div class="line"></div>
							<!-- still -->
							<div class="still">
								<c:forEach var="thumbnail" items="${thumb}" varStatus="i">
									<a style="cursor: pointer;" onclick="thumbClick('http://localhost:8081${stillcut.get(i.index).path}${stillcut.get(i.index).file_name}');">
										<img id="img_stillcut${i.index+1}" src="${thumbnail.path}${thumbnail.file_name}">
									</a>
								</c:forEach>
							</div>
							<!-- //still -->
						</div>
						<!-- //movieInfo -->
					</div>
					<!-- //description -->
				</div>
				<!-- //sub-main-section -->
			</div>
			<!-- //main-shortCut -->
		</div>
		<!-- //content -->
	</div>
	<!-- //container -->
	
	<form method="post" action="/spring-GOP/movie/buyMovie" name="buyForm">
		<input type="hidden" name="movie_num" value="${movie.movie_num}"/>
		<input type="hidden" name="movie_price" value="${movie.movie_price}"/>
		<input type="hidden" name="member_id" value="${user.member_id}"/>
		<input type="hidden" name="return_url" value="/movie/moviedetail?num=${movieNum}"/>
	</form>
</body>
</html>









































